package com.menggudf.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.menggudf.model.CaseHistoryImgModel;
import com.menggudf.model.MyCaseHistoryModel;
import com.menggudf.model.ResultModel;
import com.menggudf.service.MyCaseHistoryService;

@RequestMapping("/myCaseHistory")
@Controller
public class MyCaseHistoryController {
    
    @Autowired
    MyCaseHistoryService myCaseHistoryService;
    
    @RequestMapping("/createMyCaseHistory")
    @ResponseBody
    public ResultModel createMyCaseHistory(
            @RequestParam(value="userCode",required=false) String userCode,
            @RequestParam(value="roleCode",required=false) String roleCode,
            @RequestParam(value="illNames",required=false) String illNames,
            @RequestParam(value="symptoms",required=false) String symptoms,
            @RequestParam(value="pictures",required=false) String pictures,
            @RequestParam(value="examinations",required=false) String examinations,
            @RequestParam(value="scheme",required=false) String scheme,
            @RequestParam(value="opinion",required=false) String opinion,
            @RequestParam(value="medication",required=false) String medication){
        return myCaseHistoryService.createMyCaseHistory(
                userCode,roleCode,illNames,symptoms,pictures,
                examinations,scheme,opinion,medication);
        
    }

    @RequestMapping("/getMyCaseHistorys")
    @ResponseBody
    public Map<String, Object> getMyCaseHistorys(
            @RequestParam(value="userCode",required=false) String userCode,
            @RequestParam(value="roleCode",required=false) String roleCode,
            @RequestParam("limit") int pageSize,
            @RequestParam("offset") int offset){
                return myCaseHistoryService.getMyCaseHistorys(userCode,roleCode,pageSize,offset);
        
    }
    
    @RequestMapping("/getMyCaseHistory")
    @ResponseBody
    public MyCaseHistoryModel getMyCaseHistory(
            @RequestParam(value="id") int id){
                return myCaseHistoryService.getMyCaseHistory(id);
    }
    
    @RequestMapping("/delMyCaseHistory")
    @ResponseBody
    public ResultModel delMyCaseHistory(
            @RequestParam(value="id") int id){
                return myCaseHistoryService.delMyCaseHistory(id);
    }
    
    @RequestMapping("/createCaseHistoryImg")
    @ResponseBody
    public ResultModel createCaseHistoryImg(
            @RequestParam(value="name",required=false) String name,
            @RequestParam(value="userCode",required=false) String userCode,
            @RequestParam(value="roleCode",required=false) String roleCode,
            @RequestParam(value="imgUrl") String imgUrl){
                return myCaseHistoryService.createCaseHistoryImg(name,userCode,roleCode,imgUrl);
    }
    
    @RequestMapping("/addCaseHistoryImg")
    @ResponseBody
    public ResultModel addCaseHistoryImg(
            @RequestParam(value="code",required=false) String code,
            @RequestParam(value="imgUrl") String imgUrl){
                return myCaseHistoryService.addCaseHistoryImg(code,imgUrl);
    }
    
    @RequestMapping("/delCaseHistoryImg")
    @ResponseBody
    public ResultModel delCaseHistoryImg(
            @RequestParam(value="id") int id){
                return myCaseHistoryService.delCaseHistoryImg(id);
    }
    
    @RequestMapping("/delAllCaseHistoryImgByCode")
    @ResponseBody
    public ResultModel delAllCaseHistoryImgByCode(
            @RequestParam(value="code") String code){
                return myCaseHistoryService.delAllCaseHistoryImgByCode(code);
    }
    
    @RequestMapping("/getMyCaseHistoryImgs")
    @ResponseBody
    public Map<String, Object> getMyCaseHistoryImgs(
            @RequestParam(value="userCode",required=false) String userCode,
            @RequestParam(value="roleCode",required=false) String roleCode,
            @RequestParam("limit") int pageSize,
            @RequestParam("offset") int offset){
                return myCaseHistoryService.getMyCaseHistoryImgs(userCode,roleCode,pageSize,offset);
        
    }
    
    @RequestMapping("/getMyCaseHistoryImg")
    @ResponseBody
    public List<CaseHistoryImgModel> getMyCaseHistoryImg(
            @RequestParam(value="code") String code){
                return myCaseHistoryService.getMyCaseHistoryImg(code);
        
    }
}
